﻿using EPE.DBUtility;
using EPE.IDAL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace EPE.MySqlDAL
{
    public class UserMgrImpl:IUserMgr
    {
        public DataSet GetListByPage(string strUserName, string orderby,int pageIndex, int dataCount)
        {
            string strSQL;

            DataSet retDS = new DataSet();

            DataBaseTool clsDbTool = new DataBaseTool();

            try
            {
                strSQL = " SELECT * ";
                strSQL = strSQL + " FROM tbl_User ";
                strSQL = strSQL + " WHERE 1=1 ";

                if (!string.IsNullOrEmpty(strUserName))
                {
                    strSQL = strSQL + " AND account=@LoginName ";
                }
                

                clsDbTool.ParameterClear();
                clsDbTool.ParameterAdd("LoginName", strUserName);
                clsDbTool.CommandText = Pagination.PagingDataView(strSQL,pageIndex,dataCount,orderby);
                clsDbTool.Open();

                retDS = clsDbTool.GetDataSet();

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                clsDbTool.Close();
            }
            return retDS;
        }
    }
}
